package com.zcy.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "T_ENTITY")
public class EntityInfo extends BaseEntity {

	private static final long serialVersionUID = 1L;

	private String name;

	private String tableName;

	private Integer category;

	@JsonIgnore
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "entityInfo")
	private List<EntityRelationshipInfo> relationships;
	
	@JsonIgnore
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "entityInfo")
	private List<EntityProperty> properties;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public List<EntityRelationshipInfo> getRelationships() {
		return relationships;
	}

	public void setRelationships(List<EntityRelationshipInfo> relationships) {
		this.relationships = relationships;
	}

	public List<EntityProperty> getProperties() {
		return properties;
	}

	public void setProperties(List<EntityProperty> properties) {
		this.properties = properties;
	}

	public Integer getCategory() {
		return category;
	}

	public void setCategory(Integer category) {
		this.category = category;
	}

	public enum TABLE_CATEGORY{
		TABLE("实体对象",1), VIEW("虚拟对象",2);
		private String name;  
	    private int value; 
	    
	    private TABLE_CATEGORY(String name, int value) {
	        this.name = name;  
	        this.value = value;  
	    }
	    
	    public static String getName(int value) {  
	        for (TABLE_CATEGORY c : TABLE_CATEGORY.values()) {  
	            if (c.getValue() == value) {  
	                return c.name;  
	            }  
	        }
	        return null;  
	    }

		public String getName() {
			return name;
		}

		public int getValue() {
			return value;
		}
	    
	}
	
}
